﻿<%@ Page Title="" Language="C#" MasterPageFile="~/App_MasterPages/AdminMasterPage.master" AutoEventWireup="true" CodeFile="Paper.aspx.cs" Inherits="Admin_Paper" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeaderContentPlaceHolder" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContentPlaceHolder" Runat="Server">
  <div id="templatemo_middle_subpage" dir="rtl" align="center">
        <h2>
            مقاله ها</h2>
    </div>
   <div id="templatemo_main" dir="rtl">
        <div class="col_w900 col_w900_last">
            <table style="width: 100%" title="مقاله">
                <tr>
                    <td style="width: 90px">
                        عنوان مقاله:
                    </td>
                    <td style="width: 250px">
                        <asp:TextBox ID="PaperTitleTextBox" runat="server" Width="250px"></asp:TextBox>
                    </td>
                    <td style="width: 90px">
                        سایز صفحه:
                    </td>
                    <td style="width: 100px">
                        <asp:DropDownList ID="PageSizeDropDownList" SkinID="SearchDropDownList" runat="server">
                            <asp:ListItem Selected="True" Value="5">[پیش فرض]</asp:ListItem>
                            <asp:ListItem Value="5">5 رکورد</asp:ListItem>
                            <asp:ListItem Value="10">10 رکورد</asp:ListItem>
                            <asp:ListItem Value="15">15 رکورد</asp:ListItem>
                            <asp:ListItem Value="20">20 رکورد</asp:ListItem>
                            <asp:ListItem Value="25">25 رکورد</asp:ListItem>
                            <asp:ListItem Value="1000000">تمام رکورد ها</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <td style="width: 80px">
                        <asp:ImageButton ID="SearchImageButton" runat="server" OnClick="SearchImageButton_Click"
                            SkinID="SearchButton" />
                        <asp:ImageButton ID="ClearImageButton" runat="server" OnClick="ClearImageButton_Click"
                            OnClientClick="return false;" SkinID="ClearButton" />
                    </td>
                </tr>
                <tr>
                    <td colspan="5">
                        <table>
                            <tr>
                                <td style="width: 353px;" valign="top">
                                    <asp:GridView ID="PaperGridView" runat="server" AutoGenerateColumns="False"
                                        DataKeyNames="PaperID" DataSourceID="PaperEntityDataSource" HorizontalAlign="Center"
                                        OnSelectedIndexChanged="PaperGridView_SelectedIndexChanged" PageSize="5" Width="300px" AllowSorting="True">
                                        <Columns>
                                            <asp:TemplateField>
                                                <ItemTemplate>
                                                    <asp:ImageButton ID="SelectImageButton" runat="server" CommandName="Select" SkinID="SelectButton" />
                                                </ItemTemplate>
                                                <ItemStyle Width="25px" />
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="PaperID" Visible="False" />
                                            <asp:BoundField DataField="PaperTitle" HeaderText="عنوان مقاله" SortExpression="PaperTitle">
                                                <ItemStyle HorizontalAlign="Right" VerticalAlign="Middle" />
                                            </asp:BoundField>
                                        </Columns>
                                    </asp:GridView>
                                </td>
                                <td style="width: 20px">
                                </td>
                                <td valign="top" align="center">
                                    <asp:FormView ID="PaperFormView" runat="server" DataSourceID="PaperEntityDataSource"
                                        DataKeyNames="PaperID" DefaultMode="Insert" OnItemDeleted="PaperFormView_ItemDeleted"
                                        OnItemCommand="PaperFormView_ItemCommand" Width="500px">
                                        <EditItemTemplate>
                                            <table border="0" cellpadding="0" cellspacing="0" style="width: 500px">
                                                <tr valign="middle">
                                                    <td style="width: 80px" align="right">
                                                        عنوان :
                                                    </td>
                                                    <td style="width: 370px" align="right">
                                                        <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("PaperTitle") %>' MaxLength="500"
                                                            Width="370px" />
                                                        <asp:RequiredFieldValidator ID="TitleRequiredFieldValidator" runat="server" ControlToValidate="TitleTextBox"
                                                            Display="Dynamic" ErrorMessage="*" ValidationGroup="Update"></asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                                <tr valign="middle">
                                                    <td style="width: 80px" align="right">
                                                        تصویر  :
                                                    </td>
                                                    <td style="width: 380px" align="right">
                                                        <asp:FileUpload ID="PicFileUpload" runat="server" Width="380px" />
                                                    </td>
                                                </tr>
                                                <tr valign="middle">
                                                    <td style="width: 80px" align="right">
                                                        متن  :
                                                    </td>
                                                    <td>
                                                    </td>
                                                </tr>
                                                <tr valign="middle">
                                                    <td colspan="2" align="right" dir="rtl">
                                                        <asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>'
                                                            TextMode="MultiLine" MaxLength="2500" Height="150px" Width="480px" />
                                                        <asp:RequiredFieldValidator ID="PaperRequiredFieldValidator" runat="server" ControlToValidate="DescriptionTextBox"
                                                            Display="Dynamic" ErrorMessage="*" ValidationGroup="Update"></asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2" align="left">
                                                        <table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
                                                            <tr>
                                                                <td style="height: 15px">
                                                                </td>
                                                                <td align="left" valign="top" style="width: 80px;">
                                                                </td>
                                                                <td align="left" valign="top" style="width: 80px;">
                                                                </td>
                                                                <td align="left" valign="top" style="width: 80px;">
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td style="height: 15px">
                                                                    &nbsp;
                                                                </td>
                                                                <td align="left" valign="top" style="width: 80px">
                                                                    <asp:ImageButton ID="DeleteImageButton" runat="server" CausesValidation="False" CommandName="Delete"
                                                                        SkinID="DeleteButton" OnClientClick="if (!confirm('آيا از حذف مطمئن هستيد؟')) return false;" />
                                                                </td>
                                                                <td align="left" valign="top" style="width: 80px">
                                                                    <asp:ImageButton ID="UpdateImageButton" runat="server" CommandName="Update" SkinID="UpdateButton"
                                                                        ValidationGroup="Update" OnClientClick="if (!confirm('آيا از اعمال تغییرات مطمئن هستيد؟')) return false;" />
                                                                </td>
                                                                <td align="left" valign="top" style="width: 80px">
                                                                    <asp:ImageButton ID="CancelImageButton" runat="server" CommandName="Cancel" SkinID="CancelButton" />
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                            </table>
                                        </EditItemTemplate>
                                        <InsertItemTemplate>
                                            <table border="0" cellpadding="0" cellspacing="0" style="width: 500px">
                                                <tr valign="middle">
                                                    <td style="width: 80px" align="right">
                                                        عنوان :
                                                    </td>
                                                    <td style="width: 370px" align="right">
                                                        <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("PaperTitle") %>' MaxLength="500"
                                                            Width="370px" />
                                                        <asp:RequiredFieldValidator ID="TitleRequiredFieldValidator" runat="server" ControlToValidate="TitleTextBox"
                                                            Display="Dynamic" ErrorMessage="*" ValidationGroup="Insert"></asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                                <tr valign="middle">
                                                    <td style="width: 80px" align="right">
                                                        تصویر :
                                                    </td>
                                                    <td style="width: 380px" align="right">
                                                        <asp:FileUpload ID="PicFileUpload" runat="server" Width="380px" />
                                                    </td>
                                                </tr>
                                                <tr valign="middle">
                                                    <td style="width: 80px" align="right">
                                                        متن :
                                                    </td>
                                                    <td>
                                                    </td>
                                                </tr>
                                                <tr valign="middle">
                                                    <td colspan="2" align="right" dir="rtl">
                                                        <asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>'
                                                            TextMode="MultiLine" MaxLength="2500" Height="150px" Width="480px" />
                                                        <asp:RequiredFieldValidator ID="PaperRequiredFieldValidator" runat="server" ControlToValidate="DescriptionTextBox"
                                                            Display="Dynamic" ErrorMessage="*" ValidationGroup="Insert"></asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2" align="left">
                                                        <table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
                                                            <tr>
                                                                <td style="height: 15px">
                                                                    &nbsp;
                                                                </td>
                                                                <td align="left" valign="top" style="width: 80px;">
                                                                </td>
                                                                <td align="left" valign="top" style="width: 80px;">
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td style="height: 15px">
                                                                    &nbsp;
                                                                </td>
                                                                <td align="left" valign="top" style="width: 80px;">
                                                                    <asp:ImageButton ID="InsertButton" runat="server" CommandName="Insert" SkinID="InsertButton"
                                                                        ValidationGroup="Insert" />
                                                                </td>
                                                                <td align="left" valign="top" style="width: 80px;">
                                                                    <asp:ImageButton ID="CancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                                                                        SkinID="CancelButton" />
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                            </table>
                                        </InsertItemTemplate>
                                    </asp:FormView>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </div>
    </div>
     <asp:EntityDataSource ID="PaperEntityDataSource" runat="server" ConnectionString="name=DefaultEntityConnection"
        DefaultContainerName="DefaultEntityConnection" EntitySetName="Papers" 
        Where="(@PaperTitle is null || it.PaperTitle LIKE '%' + @PaperTitle + '%')"
        EnableUpdate="True" 
        EnableDelete="True" 
        EnableInsert="True"
        EnableFlattening="False"
        OnDeleted="PaperEntityDataSource_Command"
        OnInserted="PaperEntityDataSource_Command" 
        OnUpdated="PaperEntityDataSource_Command"
        AutoGenerateOrderByClause="True">
        <WhereParameters>
            <asp:ControlParameter ControlID="PaperTitleTextBox" Name="PaperTitle" Type="String" />
        </WhereParameters>
        <OrderByParameters>
            <asp:ControlParameter ControlID="PaperGridView" Name="OrderBy" PropertyName="SortExpression"
                Type="String" />
        </OrderByParameters>
    </asp:EntityDataSource>
    <asp:HiddenField ID="PaperIDHiddenField" runat="server" />
</asp:Content>

